<!DOCTYPE html>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>订单管理-鹿程智慧油站商户平台</title>
		<meta name="description" content="鹿程科技是提供加油站互联网化零管系统、营销及支付和大数据分析运营服务的行业领先科技公司。鹿程科技充分了解加油站行业的需求和新兴互联网的发展,依靠业内最先进的科技和标准化的运营,持续帮助油站业务发展创造价值。"/>
		<meta name="keywords" content="智慧油站,鹿程,鹿程智慧油站,鹿程智慧油站微信支付,加油站微信支付,加油站营销管理"/>
		<link rel="icon" href="https://static.zhihuiyouzhan.com.cn/static/styles/admin/img/title.ico" type="image/x-icon">
		<link rel="shortcut icon" href="https://static.zhihuiyouzhan.com.cn/static/styles/admin/img/title.ico" type="image/x-icon">
		<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../layui/css/layui.css" />
		<link rel="stylesheet" href="../css/style.css" />
	</head>
<body>
	
	<section class="section-right">
	<div class="deer-tit marke-tit">
		<h3>分时优惠活动</h3>
		<h4>添加活动</h4>
	</div>
	<article class="ware-contents">
		<!--form-->
		<form class="layui-form">
			<!--ware-content-input-->
			<section class="ware-c-input marke-c-input">
				<dl>
				    <dt><i class="must">*</i>策略名称：</dt>
				    <dd><input type="text" name="title" lay-verify="required" lay-verType="tips" placeholder="策略名称" class="layui-input"></dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>活动时间:</dt>
				    <dd><input type="text" name="sales" id="time"  placeholder="请选择活动时间" lay-verType="msg"  class="layui-input"></dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>优惠价格：</dt>
				    <dd><input type="number" name="max" min="0" lay-verify="required|num" placeholder="没升优惠多少元" lay-verType="tips" class="layui-input"></dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>会员等级：</dt>
				    <dd style="line-height: 36px;" id="checked" lay-verify="checkeds">
				    	<input type="checkbox" title="全选"  name='number' lay-filter="checked" />
				    	<input type="checkbox" title="1号枪：92#汽油" name='number1'/>
				    	<input type="checkbox" title="11号枪：90#汽油" name='number2'/>
				    	<input type="checkbox" title="2号枪：92#汽油" name='number3' />
				    	<input type="checkbox" title="3号枪：92#汽油" name='number4' />
				    	<input type="checkbox" title="7号枪：95#汽油" name='number5' />
				    	<input type="checkbox" title="1000号枪：90#汽油" name='number6' />
				    	<input type="checkbox" title="10号枪：95#汽油" name='number7' />
				    </dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>时间范围：</dt>
				    <dd style="line-height: 36px;" id="week" lay-verify="week">
				    	<input type="checkbox" title="全选"  name='week' lay-filter="week" />
				    	<input type="checkbox" title="星期一" name='week1'/>
				    	<input type="checkbox" title="星期二" name='week2'/>
				    	<input type="checkbox" title="星期三" name='week3' />
				    	<input type="checkbox" title="星期四" name='week4' />
				    	<input type="checkbox" title="星期五" name='week5' />
				    	<input type="checkbox" title="星期六" name='week6' />
				    	<input type="checkbox" title="星期日" name='week7' />
				    </dd>
			  	</dl>
			  	<dl>
			  		<dt><i class="must">*</i>状态：</dt>
			  		<dd><input type="radio" title="开启" name="open" /><input type="radio" title="关闭" name="open" /></dd>
			  	</dl>
			</section>
			<!--/ware-content-input-->
			<!--submit-->
			<div class="ware-submit">
				<button class="submit" lay-submit lay-filter="Submit" lay-verify="time">提交</button>
			</div>
			
			<!--/submit-->
		</form>
		<!--/form-->
	</article>
	</section>
	<!--js-->
	<aside>
		<script type="text/javascript" src="../layui/layui.js" ></script>
		<script type="text/javascript">
			layui.use(['form','jquery','laydate','layer'],function(){
				var form=layui.form;
				var $=layui.jquery;
				var layer=layui.layer;
				var laydate=layui.laydate;
  
				 var dateTime=laydate.render({
				  		elem:'#time',
				  		type:'time',
				  		range:'/',
				  		change: function(value, date, endDate){
						    var time=value.split("/")
						    var time1=time[0].split(':')
						    var time1s=time1[0]*3600+time1[1]*60+time1[2]
						    var time1sn=parseInt(time1s)
						    var time2=time[1].split(':')
						    var time2s=time2[0]*3600+time2[1]*60+time2[2]
						    var time2sn=parseInt(time2s)
						    
						    if(time1sn>time2sn){
						    	$('.laydate-btns-confirm').attr('lay-type','')
						    	$('.laydate-btns-confirm').css('color','#ccc')
						    	$('.laydate-btns-confirm').bind('click',function(){
						    		dateTime.hint('您所选择的开始日期大于结束日期，建议重新选择 ')
						    	})
						    }
						    if(time1sn<time2sn){
						    	$('.laydate-btns-confirm').attr('lay-type','confirm')
						    	$('.laydate-btns-confirm').css('color','#000')
						    }
						  },
	
				  })
			  	
				
				
				//表单验证
				form.verify({
			  	num: [                 //判断是否为数字
				    /^((?:[0-9]\d*))(?:\.\d{1,2})?$/
				    ,'请输入一个合理的价格'   
				]
				,checkeds:function(){
					var num=0
					$('#checked>input').each(function(index,value){
						if($(value).prop('checked')==true){
							num++
						}
					})
					if(!num){
						return "您尚未选择任何类型"
					}
				}
				,week:function(){
					var num=0
					$('#week>input').each(function(index,value){
						if($(value).prop('checked')==true){
							num++
						}
					})
					if(!num){
						return "您尚未选择时间范围"
					}
				},
				time:function(){
					if($('#time').val()==''){
						return '请选择活动时间'
					}
				}
		 		})
		 	 	//表单提交
				form.on('submit(Submit)', function(data){
					console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
					$.ajax({
			            url: '/',
			            data: data.field,
			            type: 'post',
			            datatype: 'json',
			            success: function (res) {
				                if (res.code == 1) {
				                	layer.msg(res.msg);
				                    return;
				                }
				            }
				        });
					  
					return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});
				
				
				
				
				
				
				
				
				
			//全选
			 form.on('checkbox(checked)', function(data){
                checkeds(data)
            });
			checkedAlls($('#checked'))
			form.on('checkbox(week)', function(data){
                checkeds(data)
            });
			checkedAlls($('#week'))
			
			 //判断是否全选
            function checkeds(data){
                var checkDiv=$(data.elem).parent().children('.layui-form-checkbox')
                var checked=$(data.elem).parent().children(':checkbox')
                if($(data.othis).hasClass('layui-form-checked')){
                    checkDiv.addClass('layui-form-checked')
                    checked.each(function(index,value){
                        value.checked = data.elem.checked;
                    })
                }else{
                    checkDiv.removeClass('layui-form-checked')
                    checked.each(function(index,value){
                        value.checked = data.elem.checked;
                    })
                }
            }
			//全选判断
            function checkedAlls(all){
            	var nums=0
				all.on('click','.layui-form-checkbox',function () {
					var num=0
					all.find('.layui-form-checkbox:gt(0)').each(function(index,value){
						if($(value).hasClass('layui-form-checked')==false){
							num++
						}
					})
					if(num){
						all.find('.layui-form-checkbox').eq(0).removeClass('layui-form-checked')
					}else{
						all.find('.layui-form-checkbox').eq(0).addClass('layui-form-checked')
					}
				})
				
					all.find('.layui-form-checkbox:gt(0)').each(function(index,value){
						if($(value).hasClass('layui-form-checked')==false){
							nums++
						}
					})
					if(nums){
						all.find('.layui-form-checkbox').eq(0).removeClass('layui-form-checked')
					}else{
						all.find('.layui-form-checkbox').eq(0).addClass('layui-form-checked')
					}
				
			}
			
		})
		</script>
	</aside>
	<!--/js-->
	
	
	
	
	
	
	
	
</body>
</html>